package com.roy.jarvis.config.langchian4j;

import com.roy.jarvis.assitant.ImageAnalyseAssitant;
import dev.langchain4j.agent.tool.ToolSpecification;
import dev.langchain4j.memory.ChatMemory;
import dev.langchain4j.memory.chat.ChatMemoryProvider;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.rag.content.retriever.ContentRetriever;
import dev.langchain4j.rag.content.retriever.EmbeddingStoreContentRetriever;
import dev.langchain4j.service.AiServices;
import dev.langchain4j.service.tool.ToolProvider;
import dev.langchain4j.service.tool.ToolProviderRequest;
import dev.langchain4j.service.tool.ToolProviderResult;
import dev.langchain4j.store.memory.chat.ChatMemoryStore;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;
import java.util.function.Function;

/**
 * @author 山顶洞人郑某
 * @className AssistantConfig.java ai助手配置
 * @date 2025 04 07
 */
@Configuration
public class AssistantConfig {


    /**
     * 图像分析助手
     * @return
     */
    @Bean
    public ImageAnalyseAssitant imageAnalyseAssitant(
            OpenAiChatModel openAiChatModel,
            ContentRetriever contentRetriever,
            ChatMemoryStore chatMemoryStore
            ) {
        return AiServices.builder(ImageAnalyseAssitant.class)
                .chatLanguageModel(openAiChatModel)
                .contentRetriever(contentRetriever)
                .chatMemoryProvider(o -> MessageWindowChatMemory.builder()
                        .chatMemoryStore(chatMemoryStore)
                        .id(o)
                        .maxMessages(10)
                        .build())
                .tools()
                .systemMessageProvider(o -> "你是贾维斯，托尼·斯塔克的AI助手")
                .build();
    }

}
